package controller;

import beans.Log;
import dao.LogDao;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 用于获取当前用户操作Log的具体信息
 * @author 杨凯文
 */
public class LogServlet extends HttpServlet {
    private LogDao logDao=new LogDao();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    	
    	
        int userId= Integer.parseInt(req.getParameter("user_id"));
        int page=  Integer.parseInt(req.getParameter("page"));
        List<Log> logList= logDao.getLogInfoByUserId(userId,page);
        JSONArray jsonArray=JSONArray.fromObject(logList);

        resp.getWriter().print(jsonArray.toString());


    }

}
